<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
	<title>Emissão Nota Fiscal</title>
</h:head>
<h:body>

	<h:form id="formNota">
		<p:growl id="mensagemConfirmacao" />
		<p:fieldset legend="Emitir Nota Fiscal">
			<h:panelGrid columns="1">
				<h:outputLabel value="Digite o codigo da coleta:" />
				<h:panelGrid columns="3" cellspacing="3">
					<p:inputText id="codColeta" value="#{emitirNfAction.codColeta}"
						required="true" size="6"/>
						
					<p:message for="codColeta" display="icon" />
					<p:commandButton value="Buscar" ajax="false"
						actionListener="#{emitirNfAction.procurarColeta}"
						update="mensagemConfirmacao" />
				</h:panelGrid>


				<h:outputLabel value="Local de Emissão:" />
				<p:inputText id="emissao" required="false" value="#{emitirNfAction.notaFiscal.localEmissao}" style="color:blue;"/>
				<p:message for="emissao" display="icon" />
				<br />
				<h:outputLabel value="Descrição:" />
				<br />
				<p:inputText id="descricao" required="false"  value="#{emitirNfAction.notaFiscal.descricao}" style="color:blue;" />
				<p:message for="descricao" display="icon" />
				<br />
				<h:outputText value="Data:" />
				<h:outputText value="#{emitirNfAction.dataEmissao}" style="color:blue;"/>
				
			</h:panelGrid>
			<h:panelGrid columns="2" cellspacing="1">
				<h:panelGrid columns="1">
					<p:fieldset>

						<p:fieldset>

							<legend>
								<font size="3" face="Verdana" color="#008000"> De
									(Expeditor) </font>
							</legend>

							<h:outputText value="Cliente:" />
							<br />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.nomePessoa}" style="color:blue;"/>
							<br />
							<h:outputText value="Documento:" />
							<br />
							<h:outputText rendered="#{emitirNfAction.cadFisica}" value="#{emitirNfAction.fisica.cpf}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadJuridica}" value="#{emitirNfAction.juridica.cnpj}" style="color:blue;" />
							<br />
							<h:outputText value="Endereço:" />
							<h:panelGrid columns="1">
							<h:outputText rendered=" #{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.nomeRua}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.pontoReferencia}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.bairro}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.cidade}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.uf}" style="color:blue;" />
							<h:outputText rendered="#{emitirNfAction.cadastraNotaFiscal}" value="#{emitirNfAction.coleta.cliente.endereco.cep}" style="color:blue;" />
							
						</h:panelGrid>
						</p:fieldset>
					</p:fieldset>
				</h:panelGrid>
				<h:panelGrid columns="1">
					<p:fieldset>

						<p:fieldset>
							<legend>
								<font size="3" face="Verdana" color="#008000"> Para
									(destinatário) </font>
							</legend>
							<h:outputText value="Cliente" />
							<br />
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.nomePessoa}" style="color:blue;"/>
							<br />
							<h:outputLabel value="Endereço:" />
							<h:panelGrid columns="1">
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.nomeRua}" style="color:blue;"/>
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.pontoReferencia}" style="color:blue;"/>
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.bairro}" style="color:blue;"/>
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.cidade}" style="color:blue;"/>
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.uf}" style="color:blue;"/>
							<h:outputText rendered="#{emitirNfAction.destinoFisica}" value="#{emitirNfAction.coleta.pessoa.endereco.cep}" style="color:blue;"/>
							</h:panelGrid>
							
							
						</p:fieldset>


					</p:fieldset>
				</h:panelGrid>
			</h:panelGrid>
		</p:fieldset>

		  <p:commandButton value="Salvar" onclick="confirmation.show()" type="button"/>  
     
       
     <p:confirmDialog message="Confirma a gravação dos dados?" modal="true"  
                  hideEffect="explode"  
                 header="Confirmação" severity="alert" widgetVar="confirmation">  
                  
         <p:commandButton value="Sim" update="mensagemConfirmacao" oncomplete="confirmation.hide()"  
                     actionListener="#{emitirNfAction.salvarNotaFiscal}" />  
         <p:commandButton value="Não" onclick="confirmation.hide()" type="button" />   
                   
     </p:confirmDialog>
	</h:form>

</h:body>
</html>